<html>
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>贷款管理系统</title>
    <link rel="icon" href="${createLinkTo(dir: "images", file: "favicon.ico")}" type="image/x-icon">
    <link rel="shortcut icon" href="${createLinkTo(dir: 'images', file: 'favicon.ico')}" type="image/x-icon"/>
    <asset:stylesheet src="homer/vendor/fontawesome/css/font-awesome.css"/>
    <asset:stylesheet src="homer/vendor/bootstrap/dist/css/bootstrap.css"/>
    <asset:stylesheet src="homer/style.css"/>
    <asset:stylesheet src="homer/vendor/slideUnlock/drag.css"/>
    <asset:javascript src="homer/vendor/jquery/dist/jquery.min.js"/>
    <style>
    body {
        font-family: "Microsoft YaHei", "Microsoft Sans Serif", "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", sans-serif;
    }
    input:-webkit-autofill {
        -webkit-box-shadow: 0 0 0px 1000px #fff inset !important; /*当谷歌浏览器输入框 有默认的cookie值的时候，会发现输入框背景颜色为黄色*/
    }
    .form-control, .btn {
        border-radius: 0 !important;
    }
    </style>
</head>
<body class="blank">
<!-- Simple splash screen-->
<div class="splash"><div class="color-line"></div>
    <div class="splash-title">
        <p></p>
        <div class="spinner">
            <div class="rect1"></div>
            <div class="rect2"></div>
            <div class="rect3"></div>
            <div class="rect4"></div>
            <div class="rect5"></div>
        </div>
    </div>
</div>
<div class="color-line"></div>
<div class="wholeBg">
    <div class="login-container">
        <div class="top-background"></div>
        <div class="col-md-12 smallBg">
            <div class="text-center m-b-md">
                <h3>请登录</h3>
                %{--<span>贷款管理系统</span>--}%
            </div>
            <div class="hpanel rightBox">
                <div class="panel-body">
                    <div class="helpMsg"></div>
                    <g:if test='${flash.message}'>
                        <div class='alert alert-dismissable alert-warning'>
                            <h4>Warning!</h4>
                            <p>${flash.message}</p>
                        </div>
                    </g:if>

                    <form action="/login/authenticate" method='POST' id='loginForm'>
                        <div class="form-group">
                            <label class="control-label" for="username">用户名</label>
                            <input type="text" title="Please enter you username" required="" value="" name="username"
                                   id="username" class="form-control" autofocus="autofocus">
                            <span class="help-block small" id="nameHelp">请输入用户名</span>
                        </div>

                        <div class="form-group">
                            <label class="control-label" for="password">密码</label>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <div  style="width:100%;float: left;">
                                    <input type="password" title="Please enter your password" placeholder="************"
                                           required="" value="" name="password" id="password" class="form-control">
                                </div>

                            </div>

                            <div class="clearfix"></div>

                            <span class="help-block small" id="pwdHelp">请输入密码</span>
                        </div>

                        <div class="form-group" id="code-group">
                            <div id="drag"></div>
                            <span class="help-block small" id="codeHelp">向右滑动解锁</span>
                        </div>

                        <button type="button" id="submitBtn" class="btn btn-success btn-block successLogin">登&nbsp;&nbsp;录</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

</div>

%{--<div class="row">
    <div class="col-md-12 text-center">
        <strong>Default Loan Management System</strong><br/>Copyright ? Default-2017
    </div>
</div>--}%

<asset:javascript src="homer/vendor/bootstrap/dist/js/bootstrap.min.js"/>
<asset:javascript src="homer/vendor/metisMenu/dist/metisMenu.min.js"/>
<asset:javascript src="homer/vendor/iCheck/icheck.min.js"/>
<asset:javascript src="homer/homer.js"/>
<asset:javascript src="homer/vendor/slideUnlock/drag.js"/>
<asset:javascript src="video/jquery.vidbacking.js"/>
<asset:javascript src="boc/remoteSignface/util.js"/>
<!-- <asset:javascript src="video/html5media.js"/> -->
<!-- <script src="http://html5media.googlecode.com/svn/trunk/src/html5media.min.js"></script> -->
<script>
    $(function () {
        $('#drag').drag();
        var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
        if (isMobile) {
            $("#code-group").remove();
        }


        $("#submitBtn").click(function () {
            var username = $("#username").val();
            var password = $("#password").val();
            if (!username)
            {
                helpMessage("请输入用户名");
                return;
            }
            if (!password)
            {
                helpMessage("请输入密码");
                return;
            }
            $.ajax({
                url: "/login/authenticate",
                type: "post",
                data: "username=" + $("#username").val() + "&password=" + $("#password").val(),
                success: function (data) {
                    if (data.success)
                    {
                        $.ajax({
                            url: "/remoteSignFace/getYunxinTokenByUser",
                            type: "post",
                            success: function (data) {
                                // setCookie('uid',"17610867397");
                                // setCookie('sdktoken',"ee81797e9a12dd41018b80b131558c8a");
                                setCookie('uid',data.info.accid);
                                setCookie('sdktoken',data.info.token);
                                location.href = "/remoteSignFace/remoteSignface1";
                            }})

                    }
                    else
                    {
                        helpMessage('用户名或密码错误，请重试!');
                    }
                },
                error: function (e) {
                    console.log(e)
                    $.ajax({
                        url: "/bocAppOpportunity/isLogIn",
                        type: "post",
                        success: function (data) {
                            if (data.status == 'success')
                            {
                                $.ajax({
                                    url: "/remoteSignFace/getYunxinTokenByUser",
                                    type: "post",
                                    success: function (data) {
                                        // setCookie('uid',"17610867397");
                                        // setCookie('sdktoken',"ee81797e9a12dd41018b80b131558c8a");
                                        setCookie('uid',data.info.accid);
                                        setCookie('sdktoken',data.info.token);
                                        location.href = "/remoteSignFace/remoteSignface1";
                                    }})

                            }
                            else
                            {
                                helpMessage('用户名或密码错误，请重试!');
                            }
                        },
                        error: function (e) {
                            helpMessage('用户名或密码错误，请重试!');
                        },
                    });
                },
            });
        });
        function helpMessage(message) {
            $(".helpMsg").text(message).fadeIn(200);
            setTimeout(function () {
                $(".helpMsg").fadeOut(200);
            }, 2000);
        };
    })
</script>
<script>
    $(function(){
        $('body').vidbacking({
            'masked': true
        });
    });
</script>

</body>
</html>
